<?php
class model_lhbase_authgroup extends gdl_components_basemodel 
{

    public function primarykey() {
        return 'id';
    }

    public function tableName() {
        return 'lhc_auth_group';
    }
	
	public function getInfoArg($arrg=[],$field)
    {
		if(empty($arrg)) return false;
		return $this->select($arrg, $field)->items;
    }
	
	public function getLIst($unitsid,$platform_id)
    {
		$list = [];
		$role = $this->getInfoArg(['platformId'=>$platform_id,'unitsId'=>$unitsid],'id,name');
		foreach($role as $v){
			$list[$v['id']] = [
							'id'=>$v['id'],
							'title'=>$v['name'],
							'unitsId'=>$unitsid,
							'identity'=>1,
							'children'=>[],
							]; 
		}
		
		return $list;
    }
	
	public function getLIstadmin($platform_id)
    {
		$list = [];
		$role = $this->getInfoArg(['platformId'=>$platform_id,'name'=>'Administrator','status'=>1],'id,name,unitsId');
		foreach($role as $v){
			$list[$v['unitsId']] = $v['id'];
								
		}
		
		return $list;
    }
	
	public function attendanceGroup($platform_id)
    {
		$list = [];
		$role = $this->getInfoArg(['platformId'=>$platform_id,'status'=>1,'appId'=>1],'id,title');
		foreach($role as $v){
			$list[$v['id']] = $v['title'];
								
		}
		
		return $list;
    }
	
	
	public function getDelete($groupsid)
    {
		$roleId = [0];
		
		$adminaccess = new model_lhbase_adminaccess();
		$role = $this->getInfoArg(['unitsId'=>$unitsid],'id');
		foreach($role as $v){
			$roleId[] = $v['id']; 
		}
		$adminaccess->delete('roleId in('.implode(',',$roleId).')');
		return $roleId;
    }
	
}
